//Only for Hexagon_Vertical, see TileNet.NeighborTileMoves()

//用于图案的按朝向 旋转，镜像，主要用于战场上单位的移动攻击
//用法：设置朝向，旋转朝向，角度To朝向，朝向To角度
var orientationEngine = {

	_scaleX :	[-1,	-1,		1,		1,		1,		-1],
	
	_rotation :	[0,		-30,	30,		0,		-30,	30],
	
	SetOrientation : function(node, orientation){
		node.setScaleX(node.getScaleX() * this._scaleX[orientation]);
		node.setRotation(node.getRotation() + this._rotation[orientation]);
	},
	
	TurnOrientation : function(node, ori_orientation, tgt_orientation){
		if (this._scaleX[ori_orientation] != this._scaleX[tgt_orientation]){
			node.setScaleX(node.getScaleX()
				/ this._scaleX[ori_orientation]
				* this._scaleX[tgt_orientation]
			);
		}
		if (this._rotation[ori_orientation] != this._rotation[tgt_orientation]){
			node.setRotation(node.getRotation()
				- this._rotation[ori_orientation]
				+ this._rotation[tgt_orientation]
			);
		}
	},
	
	//Heading: see TwoPointHeading()
	HeadingToOrientation : function(heading){
		var orientation = Math.round(3 - heading / 60);
		if (orientation > 5)
			orientation -= 6;
		return orientation;
	},
	
	//Heading: see TwoPointHeading()
	OrientationToHeading : function(orientation){
		var heading = (3 - orientation) * 60;
		if (heading <= -180)
			heading += 360;
		return heading;
	}
};